#ifndef LEETCODE_CN_CPP_PROBLEMS_53_H
#define LEETCODE_CN_CPP_PROBLEMS_53_H

#include <vector>

using namespace std;

namespace problem_53
{

class Solution
{
public:
    int maxSubArray(vector<int> &nums)
    {
        int maxSum = nums[0];
        for (int i = 1; i < nums.size(); ++i)
        {
            if (nums[i - 1] > 0)
                nums[i] += nums[i - 1];
            if (nums[i] > maxSum)
                maxSum = nums[i];
        }
        return maxSum;
    }
};

} // namespace problem_53

#endif //LEETCODE_CN_CPP_PROBLEMS_53_H
